package com.bruce.servicetest.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author luotuan
 * @Description
 * @create 2021-01-22 10:49
 **/
@RestController
public class HelloController {
    @GetMapping("/order/{id}")
    public String findById(@PathVariable("id") Integer orderId) {
        if (orderId == 2019) {
            return "{\n" +
                    "    \"service\":\"service1\",\n" +
                    "\t\"Id\": 1,\n" +
                    "\t\"Title\": \"饿了么订单\"\n" +
                    "}";
        }
        else {
            return "service1 订单查询失败";
        }
    }
    @GetMapping("/hello")
    public String hello() throws InterruptedException {
//        int sleepTime = ThreadLocalRandom.current().nextInt(4000);
//        Thread.sleep(sleepTime);
        return "service1 hello";
    }
}